package com.commerce.controller.api;

import com.commerce.model.FileMD5;
import com.commerce.service.FileMD5Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * restful 形式
 * 
 */
@Controller
@RequestMapping(value="/api/fileMD5")
public class FileMD5Controller {

    @Autowired
    private FileMD5Service fileMD5Service;

    /**
     * 根据md5查询数据是否存在该文件
     * @param md5
     * @return
     */
    @RequestMapping(value = "/{md5}",method = RequestMethod.GET)
    public String getMD5(@PathVariable("md5") String md5){
        FileMD5 fileMD5 = fileMD5Service.selectByMD5(md5);
        return fileMD5==null?null:fileMD5.getUrl();
    }
}
